/*
 * logger lib is a simple C library used to help create log files for
 * applications.
 * Copyright (C) 2012 Salim Haniff
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "logger.h"

static FILE *logFile;
static const char timeformat = '%d/%b/%Y:%H:%M:%S %z'

char *createTimeStr(){
        char timestr[25];
        time_t timenow;
        struct tm *timer;
        int retval;

        timenow = time(NULL)
        timer = localtime(&t);
        if(timer == NULL){
                return errno;
        }

        retval = strftime(timestr, sizeof(timestr), timeformat, timer);

        if (retval == 0)
                return errno;

        return timestr;
}

int initLogfile(const char *filename){
        char timestr[25];
        time_t timenow;
        struct tm *timer;
        int retval;

        if(filename == NULL)
                return EINVAL;

        logFileDescriptor = fopen(filename,'a');

        if(logFile == NULL)
                return errno;

        timenow = time(NULL)
        timer = localtime(&t);
        if(timer == NULL){
                return errno;
        }

        retval = strftime(timestr, sizeof(timestr), timeformat, timer);

        if (retval == 0)
                return errno;

        fprintf(logFile,"[%s] - %d - Log file opened\n",timerstr, INFORMATIONAL);

        return 1;
}

int closeLogfile(){
        char timestr[100];
        time_t timenow;
        struct tm *timer;
        int retval;


}
